#include "camprec.h"
#include "OpenGLError.h"              

#include "definitions.h"

DWORD COpenGLError::m_ID = 0;

COpenGLError::COpenGLError()
{
	m_ID++; ID = m_ID;
	//StrID (mystr::format(_T("OpenGLError%d"),m_ID));
}

COpenGLError::~COpenGLError(){}

bool COpenGLError::CheckOpenGLError (const wxString &Message, const int &paramOutError)
	{
		if (glGetError () == GL_NO_ERROR)
			return false;
 
		wxString s;
		switch (glGetError ())
		{
		case GL_INVALID_ENUM:
			s = s.Format (_T("%s (%s)"), Message.c_str(), _T("GL_INVALID_ENUM"));
			break;
		case GL_INVALID_VALUE:
			s = s.Format (_T("%s (%s)"), Message.c_str(), _T("GL_INVALID_VALUE"));
			break;
		case GL_INVALID_OPERATION:
			s = s.Format (_T("%s (%s)"), Message.c_str(), _T("GL_INVALID_OPERATION"));
			break;
		case GL_STACK_OVERFLOW:	
			s = s.Format (_T("%s (%s)"), Message.c_str(), _T("GL_STACK_OVERFLOW"));
			break;
		case GL_STACK_UNDERFLOW:
			s = s.Format (_T("%s (%s)"), Message.c_str(), _T("GL_STACK_UNDERFLOW"));
			break;
		case GL_OUT_OF_MEMORY:
			s = s.Format (_T("%s (%s)"), Message.c_str(), _T("GL_OUT_OF_MEMORY"));
			break;
		default:
			s = s.Format (_T("%s (%s)"), Message.c_str(), _T("Unknown error"));
			break;
		}

		PRINT_ERROR (s);

		return true;
	}